﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace MsTestUtilities.Utilities
{
    public static class PathUtilities
    {
        public static string Collapse(string path)
        {        
            var upMatcher = new Regex(@"[^\\\.:]+\\\.\.\\");
            var result = upMatcher.Replace(path, string.Empty);            

            if (result != path)
            {
                return Collapse(result);
            }

            return result;
        }
    }
}
